let appDepartment = new Vue({
    el:"#appDepartment",
    data:{
        departmentName:"",
        officeName:"",
        chairman:"",
        status:""
    },methods:{
        addDepartment:function () {
            let form=new FormData();
            //从各相关元素中获取填入的信息并填入form表单
            appDepartment.departmentName=$("#validationCustom01").val();
            form.append("name",appDepartment.departmentName);
            appDepartment.officeName=$("#validationCustom02").val();
            form.append("officeName",appDepartment.officeName);
            appDepartment.chairman=$("#validationCustom04").val();
            form.append("chairman", appDepartment.chairman);
            let selectStatus= document.getElementsByName("status");
            //判断状态选项
            for (let i = 0; i < selectStatus.length; i++) {
                if (selectStatus.item(i).checked) {
                    appDepartment.status= selectStatus.item(i).getAttribute("value")
                }
            }
            form.append("status",appDepartment.status)
            console.log(form);
            //异步上传信息
            axios({
                url:"/portal/departmentOffice/add_department",
                method:"POST",
                data: form
            }).then(function (r) {
                console.log("传送成功")
                if(r.data!="添加成功"){
                    alert(r.data)
                    return;
                }
                location.href="/pages/department/department-list.html";
            })
        },
        //重新填写信息
        clearAll:function () {
            console.log("清空所有" )
            //清空所有已填信息
            $(".info").val("");
        },

    }
})